import os
from multiprocessing import Process


class MyProcess(Process):
    def __init__(self, name):
        super().__init__()
        self.name = name

    def run(self):
        print(os.getpid())
        print(f'{self.name}子进程运行了')


if __name__ == '__main__':
    p1 = MyProcess('1号')
    p2 = MyProcess('2号')
    p3 = MyProcess('3号')

    p1.start()  # start会自动调用run
    p2.start()
    # p2.run()
    p3.start()

    print('主线程')
